package com.hitqz.robot.driver.zmq.protocol.handler;

import com.hitqz.robot.driver.util.WheelCacheUtil;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import navconnector.ChassisYichun;
import navconnector.NavconnectorBase;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.concurrent.locks.Lock;

/**
 * ChassisInt32Array数据对象处理类
 *
 * @author wengyx
 * @date 2021-09-14 23:05
 **/
@Slf4j
@Component
public class ChassisInt32ArrayHandler implements HandlerZMQService {

    @Override
    public void handlerMsg(String robotSn, byte[] data) throws Exception {
        ChassisYichun.ChassisInt32Array chassisInt32Array = ChassisYichun.ChassisInt32Array.parseFrom(data);
        int objId = chassisInt32Array.getHeader().getObj();
        int ackId = chassisInt32Array.getHeader().getAck();
        switch (objId) {
            //升降杆状态 主动上报
            case ChassisYichun.ChassisInt32Array.OBJ_ID.NUL_JACKING_MECHANISM_NTF_VALUE:
                HashMap<String, Integer> jackingStatusMap = new HashMap<>();
                jackingStatusMap.put("lift_status", chassisInt32Array.getData(0));
                jackingStatusMap.put("rotation_status", chassisInt32Array.getData(1));
                jackingStatusMap.put("distance", chassisInt32Array.getData(2));
                WheelCacheUtil.put(WheelCacheUtil.KEY_JACKING_STATUS,jackingStatusMap);
                break;
            default:
                break;
        }


    }

}
